package com.ruoyi.buss.hourse.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.hourse.domain.DataHoursePrice;
import com.ruoyi.buss.hourse.service.IDataHoursePriceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 抵押品小区评估价格Controller
 * 
 * @author sxy
 * @date 2022-04-08
 */
@RestController
@RequestMapping("/hoursePrice")
public class DataHoursePriceController extends BaseController
{
    @Autowired
    private IDataHoursePriceService dataHoursePriceService;

    /**
     * 查询抵押品小区评估价格列表
     */
    @PreAuthorize(hasPermi = "buss:hoursePrice:list")
    @GetMapping("/list")
    public TableDataInfo list(DataHoursePrice dataHoursePrice)
    {
        startPage();
        List<DataHoursePrice> list = dataHoursePriceService.selectDataHoursePriceList(dataHoursePrice);
        return getDataTable(list);
    }

    /**
     * 导出抵押品小区评估价格列表
     */
    @PreAuthorize(hasPermi = "buss:hoursePrice:export")
    @Log(title = "抵押品小区评估价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataHoursePrice dataHoursePrice) throws IOException
    {
        List<DataHoursePrice> list = dataHoursePriceService.selectDataHoursePriceList(dataHoursePrice);
        ExcelUtil<DataHoursePrice> util = new ExcelUtil<DataHoursePrice>(DataHoursePrice.class);
        util.exportExcel(response, list, "抵押品小区评估价格数据");
    }

    /**
     * 获取抵押品小区评估价格详细信息
     */
    @PreAuthorize(hasPermi = "buss:hoursePrice:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(dataHoursePriceService.selectDataHoursePriceById(id));
    }

    /**
     * 新增抵押品小区评估价格
     */
    @PreAuthorize(hasPermi = "buss:hoursePrice:add")
    @Log(title = "抵押品小区评估价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataHoursePrice dataHoursePrice)
    {
        return toAjax(dataHoursePriceService.insertDataHoursePrice(dataHoursePrice));
    }

    /**
     * 修改抵押品小区评估价格
     */
    @PreAuthorize(hasPermi = "buss:hoursePrice:edit")
    @Log(title = "抵押品小区评估价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataHoursePrice dataHoursePrice)
    {
        return toAjax(dataHoursePriceService.updateDataHoursePrice(dataHoursePrice));
    }

    /**
     * 删除抵押品小区评估价格
     */
    @PreAuthorize(hasPermi = "buss:hoursePrice:remove")
    @Log(title = "抵押品小区评估价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(dataHoursePriceService.deleteDataHoursePriceByIds(ids));
    }
}
